﻿/**
 * 
 * @file FITKRadiossRadIoInterface.h
 * @brief Interface for the FITKRadiossRadIO component
 * @author LiBaojun (libaojunqd@foxmail.com)
 * @date 2025-06-17
 * 
 */
#ifndef _FITKRadiossRadIoInterface_H_
#define _FITKRadiossRadIoInterface_H_

#include <QObject>
#include "FITKRadiossRadIOAPI.h"
#include "FITK_Kernel/FITKAppFramework/FITKComponentInterface.h"
#include "FITK_Kernel/FITKCore/FITKAbstractObjectContainer.hpp"
namespace Interface
{
    class FITKAbstractIO;
}
namespace Radioss
{
     /**
      * @brief Interface for the FITKRadiossRadIO component
      * @author LiBaojun (libaojunqd@foxmail.com)
      * @date 2025-06-17
      */
    class FITKRadiossRadIOAPI FITKRadiossRadIoInterface : public QObject, public AppFrame::FITKComponentInterface
    {
        Q_OBJECT
    public:
        explicit FITKRadiossRadIoInterface() = default;
        virtual ~FITKRadiossRadIoInterface()  =default;

        /**
         * @brief Execute the I/O operation
         * @param[i]  indexPort      1 for read, 2 for write
         * @return true  成功,多线程执行时候返回值无效
         * @return false 失败，多线程执行时候返回值无效
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2025-06-17
         */
        bool exec(const int indexPort) override;
        /**
         * @brief 设置文件名称
         * @param[i]  fileName      文件名称，要求包含绝对路径
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2025-06-17
         */
        void setFileName(const QString& fileName);
        /**
         * @brief 是否在独立线程执行读写
         * @param[i]  inThread       是否在独立线程执行读写操作
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2025-06-17
         */
        void runInThread(const bool & inThread = true);
        /**
         * @brief 是否正在执行
         * @return true
         * @return false
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2025-06-17
         */
        bool isRunning();
        /**
         * @brief 执行是否成功
         * @return true
         * @return false
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2025-06-17
         */
        bool isSuccess();
        /**
         * @brief 获取部件名称，不能重复  返回 FITKRadiossRadIO
         * @return QString
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2025-06-17
         */
        QString getComponentName() override;

    signals:
        /**
         * @brief 读写线程结束信号
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2025-06-17
         */
        void ioThreadFinishedSig();

    private:
        /**
         * @brief 文件名称
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2025-06-17
         */
        QString _fileName{};
        /**
         * @brief 是否在线程运行
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2025-06-17
         */
        bool _runInThread{ true };
        /**
         * @brief 是否执行成功标记
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2025-06-17
         */
        bool _success{ false };
        /**
         * @brief io 对象
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2025-06-17
         */
        Core::FITKAbstractObjectContainer<Interface::FITKAbstractIO> _io{ nullptr };
    };
}
#endif
